package code.generate;

import java.io.StringReader;
import java.io.StringWriter;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.Template;

public class TemplateProcessor {
	
	
	public static String processTemplateString(String templateString,Map<?, ?> model,Configuration conf) {
		StringWriter out = new StringWriter();
		try {
			Template template = new Template("templateString...",new StringReader(templateString),conf);
			template.process(model, out);
			return out.toString();
		}catch(Exception e) {
			throw new IllegalStateException("cannot process templateString:"+templateString+" cause:"+e,e);
		}
	}
}
